<!--
 * @Author: wangming
 * @Date: 2021-03-26 14:10:26
 * @LastEditors: wangming
 * @LastEditTime: 2022-02-07 17:33:43
 * @Description: file content
-->
<template>
  <el-container class="process-design-wrap" v-loading="processLoading">
    <!-- 头部组件 -->

    <el-header class="page-header">
      <div class="process-header">
        <div class="process-header_title">{{ modelData.name }}</div>
        <div>
          <el-select
            style="width: 240px; margin-right: 10px"
            v-model="curVersion"
            placeholder="请选择版本"
            @change="handleCurVersionChange"
          >
            <el-option
              v-for="ver in versionList"
              :key="ver.id"
              :value="ver.id"
              :label="ver.versionText"
            >
            </el-option>
          </el-select>
          <el-button
            v-show="processCanEdit"
            style="margin-right: 10px"
            icon="el-icon-setting"
            @click="handleGlobalSetting"
            >全局配置
          </el-button>
          <el-dropdown
            split-button
            type="primary"
            @click="handleSave(true)"
            @command="handleCommandSave"
          >
            <i class="el-icon-upload"></i>
            <span>保存</span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                :disabled="!processCanActivate"
                command="activate"
                >保存并激活</el-dropdown-item
              >
              <el-dropdown-item :disabled="!processCanPublish" command="publish"
                >保存并发布</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>

          <el-button style="margin-left: 10px" @click="handleClose"
            >关闭页面
          </el-button>
        </div>
        <!-- <div>
          <el-button icon="el-icon-setting" @click="handleGlobalSetting">全局配置</el-button>
          <el-button @click="handleSave">保存</el-button>
          <el-button type="primary" @click="handlePublish">发布</el-button>
        </div> -->
      </div>

      <div class="toolbar">
        <template v-if="processCanEdit">
          <el-tooltip content="撤销" placement="bottom">
            <div class="toolbar_item" @click="handleUndo">
              <i class="el-icon-arrow-left"></i>
            </div>
          </el-tooltip>

          <el-tooltip content="重做" placement="bottom">
            <div class="toolbar_item" @click="handleRedo">
              <i class="el-icon-arrow-right"></i>
            </div>
          </el-tooltip>

          <span class="divider"></span>
        </template>

        <el-tooltip content="放大" placement="bottom">
          <div class="toolbar_item" @click="handleZoom(0.2)">
            <i class="el-icon-zoom-in"></i>
          </div>
        </el-tooltip>

        <el-tooltip content="还原" placement="bottom">
          <div class="toolbar_item" @click="handleZoom(0)">
            <i class="el-icon-help"></i>
          </div>
        </el-tooltip>

        <el-tooltip content="缩小" placement="bottom">
          <div class="toolbar_item" @click="handleZoom(-0.2)">
            <i class="el-icon-zoom-out"></i>
          </div>
        </el-tooltip>

        <template v-if="processCanEdit">
          <span class="divider"></span>

          <el-tooltip content="导入" placement="bottom">
            <div class="toolbar_item" @click="importXml">
              <i class="el-icon-upload2"></i>
            </div>
          </el-tooltip>

          <el-upload action="" :before-upload="openBpmn" style="display: none">
            <el-button
              ref="importBtn"
              size="mini"
              icon="el-icon-folder-opened"
            />
          </el-upload>

          <el-tooltip content="导出XML" placement="bottom">
            <div class="toolbar_item" @click="handleExportXmlAction">
              <span>XML</span>
            </div>
          </el-tooltip>

          <el-tooltip content="导出SVG" placement="bottom">
            <div class="toolbar_item" @click="handleExportSvgAction">
              <span>SVG</span>
            </div>
          </el-tooltip>

          <span class="divider"></span>

          <el-tooltip content="预览" placement="bottom">
            <div class="toolbar_item" @click="handlePreviewXml">
              <i class="el-icon-view"></i>
            </div>
          </el-tooltip>

          <el-tooltip content="清空" placement="bottom">
            <div class="toolbar_item" @click="handleClear">
              <i class="el-icon-delete"></i>
            </div>
          </el-tooltip>
        </template>

        <!-- <el-tooltip content="全局配置" placement="bottom">
          <div class="toolbar_item" @click="handleGlobalSetting">
            <i class="el-icon-setting"></i>
          </div>
        </el-tooltip> -->

        <!-- <el-tooltip content="保存" placement="bottom">
          <div class="toolbar_item" @click="handleSave">
            <i class="el-icon-upload"></i>
          </div>
        </el-tooltip> -->
      </div>
    </el-header>
    <el-container class="process-container">
      <!-- 左侧组件 -->
      <el-aside width="200px" class="left-aside" v-show="processCanEdit">
        <div class="process-nodes">
          <el-collapse v-model="activeKeys">
            <el-collapse-item title="工具" name="1">
              <div class="process-nodes-content">
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="hand-tool"
                >
                  <i class="el-icon-thumb"></i>
                  <span>移动工具</span>
                </a>

                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="lasso-tool"
                >
                  <i class="el-icon-full-screen"></i>
                  <span>选择工具</span>
                </a>

                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="space-tool"
                >
                  <i class="el-icon-crop"></i>
                  <span>空间工具</span>
                </a>

                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="global-connect-tool"
                >
                  <i class="el-icon-top-right"></i>
                  <span>连接工具</span>
                </a>
              </div>
            </el-collapse-item>
            <el-collapse-item title="开始结束" name="2">
              <div class="process-nodes-content">
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.end-event"
                >
                  <i class="el-icon-video-pause"></i>
                  <span>结束节点</span>
                </a>
              </div>
            </el-collapse-item>
            <el-collapse-item title="服务" name="3">
              <div class="process-nodes-content">
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.user-task"
                >
                  <i class="el-icon-user"></i>
                  <span>用户任务</span>
                </a>
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.service-task"
                >
                  <i class="el-icon-setting"></i>
                  <span>服务任务</span>
                </a>
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.service-script-task"
                >
                  <i class="el-icon-document-copy"></i>
                  <span>脚本任务</span>
                </a>
                <!-- <a class="process-node entry" draggable="true" data-action="create.script-task">
                  <i class="el-icon-document-copy"></i>
                  <span>脚本任务</span>
                </a> -->
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.receivetask"
                >
                  <i class="el-icon-message"></i>
                  <span>接收任务</span>
                </a>
                <!-- <a class="process-node entry" draggable="true" data-action="create.send-task">
                  <i class="el-icon-position"></i>
                  <span>发送任务</span>
                </a> -->
              </div>
            </el-collapse-item>
            <el-collapse-item title="网关" name="4">
              <div class="process-nodes-content">
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.exclusive-gateway"
                >
                  <i class="el-icon-circle-close"></i>
                  <span>排他网关</span>
                </a>
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.parallel-gateway"
                >
                  <i class="el-icon-circle-plus-outline"></i>
                  <span>并行网关</span>
                </a>
                <a
                  class="process-node entry"
                  draggable="true"
                  data-action="create.inclusive-gateway"
                >
                  <i class="el-icon-remove-outline"></i>
                  <span>包容网关</span>
                </a>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>
      </el-aside>
      <el-main class="container">
        <div class="canvas" ref="canvas" />
      </el-main>
      <el-aside
        width="480px"
        class="right-aside"
        :class="{ 'right-aside_visible': rightVisible }"
      >
        <!-- 右侧面板 -->
        <bpmn-element
          ref="_bpmnElement"
          v-if="modeler"
          :modeler="modeler"
          :modelData="modelData"
          :curVersion="curVersion"
        />
      </el-aside>
    </el-container>

    <el-dialog :visible.sync="xmlVisible" title="预览" center fullscreen>
      <vue-ace-editor
        v-model="process.xml"
        @init="editorInit"
        lang="xml"
        theme="chrome"
        width="100%"
        height="calc(100vh - 120px)"
        :options="{ wrap: true, readOnly: true }"
      >
      </vue-ace-editor>
    </el-dialog>
  </el-container>
</template>

<script>
import { mapGetters } from "vuex";
import { cloneDeep, debounce } from "lodash";
import { beforeunload } from "@/utils/mixins";
import BpmnElement from "./__components__/BpmnElement";
// 引入flowable的节点文件
import flowableModdle from "./__components__/descriptors/flowable.json";
import newXml from "./__components__/resources/newDiagram.js";
import { Message } from "element-ui";
import VueAceEditor from "vue2-ace-editor";

import { CustomModeler } from "./__components__/customerConfig/modeler";
// import BpmnViewer from 'bpmn-js/lib/Viewer'

import {
  getFields,
  setFields,
  globalValidate,
  additionalSymbolTags,
  additionalStyle,
} from "./__components__/utils/util";

import {
  getHmprocessInfo,
  getHmprocessHistory,
  putHmprocessDeploy,
  putHmprocessPublish,
  putHmprocessActivate,
} from "@/apis/paas/HmProcessController.js";

export default {
  name: "ProcessDesign",
  // mixins: [beforeunload],
  layout: "formlayout",
  components: {
    BpmnElement,
    VueAceEditor,
  },
  props: {
    isView: {
      type: Boolean,
      default: false,
    },
  },

  data() {
    // this.hideLoading = debounce(this.hideLoading, 300)
    return {
      processLoading: false,
      name: "home",
      activeKeys: ["1", "2", "3", "4"],
      formList: [],
      scale: 1, // 流程图比例（用于放大缩小）
      modeler: null,
      process: {
        xml: "",
        svg: "",
      },
      xmlVisible: false,
      idTest: /^[a-z_][\w-.]*$/i,

      modelData: {
        id: undefined,
        key: "",
        name: "",
        category: "",
        description: "",
      },

      curVersion: undefined,
      versionList: [],
    };
  },

  computed: {
    curVerssionData() {
      const { curVersion, versionList } = this;
      if (!curVersion) {
        return undefined;
      } else {
        return versionList.find((ver) => ver.id === curVersion);
      }
    },
    ...mapGetters([
      "processCanActivate",
      "processCanPublish",
      "processCanEdit",
      "rightVisible",
    ]),
  },

  created() {
    const { id, key } = this.$route.query;
    this._id = id ? Number(id) : undefined;
    this._key = key;
    this.curVersion = this._id;
    this.loadVersionList(this._key);
  },

  mounted() {
    this.initProcess();
  },

  methods: {
    loadVersionList(key = "") {
      getHmprocessHistory({
        key,
      }).then((res) => {
        this.versionList = res.map((item) => {
          item.versionText =
            this.$options.filters["version"](item.version) +
            `${item.published ? "【已发布】" : ""}` +
            `${item.activated ? "【已激活】" : ""}`;
          return item;
        });
        this.$store.commit("SET_PROCESS_DATA", cloneDeep(this.curVerssionData));
      });
    },

    /**
     * 版本切换
     */
    handleCurVersionChange() {
      this.$store.commit("SET_RIGHT_ASIDE_VISIBLE", false);
      const { id } = this.curVerssionData;
      const url = window.location.href.replace(/id=\d*/, `id=${id}`);
      this.processLoading = true;
      window.location.replace(url);
      window.location.reload();
    },

    /**
     * 初始化流程图
     */
    initProcess() {
      if (!this.curVersion) {
        return;
      }
      // this.initData()
      // 获取到属性ref为“canvas”的dom节点
      const canvas = this.$refs.canvas;

      getHmprocessInfo({
        id: this.curVersion,
        includeXml: true,
      }).then((res) => {
        this.modelData = {
          ...res,
          category: res.folderName,
        };

        // if (this.modeler) {
        //   this.modeler.destroy()
        //   this.modeler = null
        // }

        // this.modeler = new CustomModeler({
        //   container: canvas,
        //   moddleExtensions: {
        //     flowable: flowableModdle
        //   }
        // })

        if (!this.modeler) {
          this.modeler = new CustomModeler({
            container: canvas,
            moddleExtensions: {
              flowable: flowableModdle,
            },
            additionalModules: {
              // 禁止双击节点出现label编辑框
              labelEditingProvider: ["value", ""],
            },
          });
        }

        // 新增流程定义
        // this.createNewDiagram(this.modelData?.editor)
        this.$nextTick(() => {
          this.createNewDiagram(res.json);
        });
      });
    },

    // init ace editor
    editorInit: function () {
      require("brace/ext/language_tools");
      require("brace/mode/xml");
      require("brace/theme/chrome");
    },

    getProcessElement() {
      return this.modeler.getDefinitions().rootElements[0];
    },

    getProcess() {
      const element = this.getProcessElement();
      return {
        id: element.id,
        name: element.name,
        category: element.$parent.targetNamespace,
      };
    },
    // 初始化流程图
    async createNewDiagram(xml) {
      if (!xml) {
        // 初始化XML文本
        this.process.xml = newXml(
          this.modelData.key,
          this.modelData.name,
          this.modelData.category,
          this.modelData.description
        );
      } else {
        this.process.xml = xml;
      }

      try {
        const result = await this.modeler.importXML(this.process.xml);
        const { warnings } = result;
        console.log(warnings);
        // 复制流程的name，id
        const query = this.$route.query;
        const element = this.getProcessElement();
        // 解决流程复制后，name，id数据还是老数据的问题
        if (query?.key && query.key !== element.id) {
          element.id = query.key;
        }
        if (query?.name && query.name !== element.name) {
          element.name = query.name;
        }
      } catch (err) {
        console.log(err.message, err.warnings);
      }
      /*
      // 将字符串转换成图显示出来
      this.modeler.importXML(this.process.xml, err => {
        if (err) {
          console.error(err)
        } else {
          // this.adjustPalette()
        }
      })

       */
    },
    // 当图发生改变的时候会调用这个函数，这个data就是图的xml
    setEncoded(type, data) {
      // 把xml转换为URI，下载要用到的
      const encodedData = encodeURIComponent(data);
      if (data) {
        if (type === "xml") {
          // 获取到图的xml，保存就是把这个xml提交给后台
          this.process.xml = data;
          return {
            filename: this.process.name + ".bpmn20.xml",
            href: "data:application/bpmn20-xml;charset=UTF-8," + encodedData,
            data: data,
          };
        }
        if (type === "svg") {
          this.process.svg = data;
          return {
            filename: this.process.name + ".bpmn20.svg",
            href: "data:application/text/xml;charset=UTF-8," + encodedData,
            data: data,
          };
        }
      }
    },
    // 导入
    importXml() {
      this.$refs.importBtn.$el.click();
    },
    // 导入文件选择完成
    openBpmn(file) {
      const reader = new FileReader();
      reader.readAsText(file, "utf-8");
      reader.onload = () => {
        this.createNewDiagram(reader.result);
      };
      return false;
    },
    /**
     * 下载xml/svg
     *  @param  type  类型  svg / xml
     *  @param  data  数据
     *  @param  name  文件名称
     */
    download(type, data, name) {
      let dataTrack = "";
      const a = document.createElement("a");
      switch (type) {
        case "xml":
          dataTrack = "bpmn";
          break;
        case "svg":
          dataTrack = "svg";
          break;
        default:
          break;
      }
      name = name || `diagram.${dataTrack}`;
      a.setAttribute(
        "href",
        `data:application/bpmn20-xml;charset=UTF-8,${encodeURIComponent(data)}`
      );
      a.setAttribute("target", "_blank");
      a.setAttribute("dataTrack", `diagram:download-${dataTrack}`);
      a.setAttribute("download", name);
      document.body.appendChild(a);
      a.click();
      URL.revokeObjectURL(a.href); // 释放URL 对象
      document.body.removeChild(a);
    },
    // 导出XML文件
    handleExportXmlAction() {
      const _this = this;
      this.modeler.saveXML({ format: true }, function (err, xml) {
        _this.download("xml", xml, _this.getProcess().name + ".bpmn20.xml");
        err && console.log(err);
      });
    },
    // 导出SVG文件
    handleExportSvgAction() {
      const _this = this;
      this.modeler.saveSVG({ format: true }, function (err, svg) {
        _this.download(
          "svg",
          svg.replace(
            `<defs>`,
            `${additionalSymbolTags}<style>${additionalStyle}</style><defs>`
          ),
          _this.getProcess().name + ".bpmn20.svg"
        );
        err && console.log(err);
      });
    },
    // 预览
    handlePreviewXml() {
      console.log(this.modeler);
      this.modeler.saveXML({ format: true }, (err, xml) => {
        this.process.xml = xml;
        this.xmlVisible = true;
        err && console.log(err);
      });
    },

    // 清空
    handleClear() {
      this.createNewDiagram();
    },

    showLoading() {
      this.processLoading = true;
    },
    hideLoading() {
      this.processLoading = false;
    },

    // 保存
    async handleSave(showMsg = true) {
      const validateResult = globalValidate(this.modeler);
      console.log("validateResult", validateResult);
      const { element, valid, error, errorTab } = validateResult;
      if (!valid) {
        if (!element) {
          this.$message.error(error);
        } else {
          // 有指定节点时触发节点点击
          // 根节点时手动调出全局配置
          const domElement = document.querySelector(
            `.process-container [data-element-id=${element.id}]`
          );
          const event = document.createEvent("MouseEvents");
          event.initEvent("click", true, true);
          domElement.dispatchEvent(event);
          element.type === "bpmn:Process" &&
            this.$refs._bpmnElement.handleGlobalSetting();
        }
        this.$nextTick(() => {
          this.$refs._bpmnElement.validate(errorTab);
          this.hideLoading();
        });
        return Promise.reject(new Error("global valid error"));
      }

      const _this = this;
      await this.$nextTick();
      // eslint-disable-next-line no-unused-expressions
      const flag = true;
      // 仅当节点属性面板打开时校验
      if (this.$refs._bpmnElement.$refs._component) {
        // flag = await this.$refs._bpmnElement.validate()
      }
      if (flag) {
        const processId = this.getProcess().id;
        if (!this.idTest.test(processId)) {
          Message.error("流程标识key格式不正确");
        }

        const result = await this.modeler.saveXML({ format: true });
        const { xml } = result;
        console.log(xml);
        // debugger
        const process = _this.getProcess();
        _this.process.xml = xml;
        _this.modelData.editor = xml;
        _this.modelData.key = process.id;
        _this.modelData.name = process.name;
        _this.modelData.category = process.category;
        this.showLoading();
        return putHmprocessDeploy({
          id: this.modelData.id,
          json: encodeURIComponent(xml),
        })
          .then((res) => {
            showMsg && this.$message.success("保存成功");
          })
          .finally(() => {
            this.hideLoading();
          });
      } else {
        this.hideLoading();
        return Promise.reject(new Error("node valid error"));
      }
    },

    async handleCommandSave(command) {
      await this.handleSave(false);
      if (command === "activate") {
        this.handleActivate();
      } else if (command === "publish") {
        this.handlePublish();
      }
    },

    async handleActivate() {
      this.showLoading();
      putHmprocessActivate({
        id: this.modelData.id,
      })
        .then((res) => {
          this.$message.success("操作成功");
          this.loadVersionList(this.modelData.key);
        })
        .finally(() => {
          this.hideLoading();
        });
    },

    async handlePublish() {
      this.showLoading();
      putHmprocessPublish({
        id: this.modelData.id,
      })
        .then((res) => {
          this.$message.success("操作成功");
          this.loadVersionList(this.modelData.key);
          // 发布成功以后 手动触发当前选中节点的点击 以 更新 面板动作及属性
          const domElement = document.querySelector(".djs-element.selected");
          if (!domElement) {
            return;
          }
          const event = document.createEvent("MouseEvents");
          event.initEvent("click", true, true);
          domElement.dispatchEvent(event);
        })
        .finally(() => {
          this.hideLoading();
        });
    },

    // 复制成功
    onCopy() {
      this.$message.success("内容复制成功");
    },
    // 前进
    handleRedo() {
      this.modeler.get("commandStack").redo();
    },
    // 后退
    handleUndo() {
      this.modeler.get("commandStack").undo();
    },
    // 流程图放大缩小
    handleZoom(radio) {
      const newScale = !radio
        ? 1.0 // 不输入radio则还原
        : this.scale + radio <= 0.2 // 最小缩小倍数
        ? 0.2
        : this.scale + radio;
      this.modeler.get("canvas").zoom(newScale);
      this.scale = newScale;
    },
    back() {
      this.close();
    },
    async close() {
      await this.$router.go(-1);
    },
    goPreview() {
      this.$router.push({
        name: this.$route.name,
        query: Object.assign({}, this.$route.query, { preview: this.name }),
      });
    },

    handleGlobalSetting() {
      this.$refs._bpmnElement.handleGlobalSetting();
    },
    handleClose() {
      window.close();
    },
  },
};
</script>

<style lang="scss" scoped>
/*左边工具栏以及编辑节点的样式*/
// @import "/node_modules/bpmn-js/dist/assets/diagram-js.css";
// @import "/node_modules/bpmn-js/dist/assets/bpmn-font/css/bpmn.css";
// @import "/node_modules/bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css";
// @import "/node_modules/bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css";

.process-design-wrap {
  height: 100%;
}

.process-node {
  display: inline-block;
  height: 62px;
  width: 50%;
  margin: 0 0 20px 0;
  border-radius: 4px;
  box-sizing: border-box;
  text-align: center;
  padding-top: 10px;
  font-size: 12px;
  cursor: pointer;

  i {
    font-size: 18px;
    display: block;
    margin-bottom: 10px;
  }

  span {
    display: block;
  }
}

.process-node:hover {
  background: #b4bccc;
}

.process-node-type-text {
  padding: 5px 10px;
  cursor: pointer;
  margin-bottom: 5px;

  i {
    font-size: 16px;
    margin-right: 5px;
  }
}

.container {
  padding: 0;

  .canvas {
    width: 100%;
    height: 100%;
    overflow: auto;
    background-image: linear-gradient(
        90deg,
        rgba(220, 220, 220, 0.5) 6%,
        transparent 0
      ),
      linear-gradient(rgba(192, 192, 192, 0.5) 6%, transparent 0);
    background-size: 12px 12px;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
  }
}

.page-header {
  height: 100px !important;
  position: relative;
  padding: 0;
}

.process-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 0 28px;

  .process-header_title {
    font-size: 18px;
  }
}

.toolbar {
  height: 40px;
  display: flex;
  align-items: center;
  border-top: 1px solid #dcdfe6;
  border-bottom: 1px solid #dcdfe6;
  padding-left: 20px;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  box-sizing: border-box;

  &_item {
    padding: 0 20px;
    cursor: pointer;
    height: 28px;
    display: flex;
    align-items: center;
    border-radius: 3px;
    transition: all 0.3s;

    &:hover {
      background: #eee;
    }
  }

  & > i:not(.divider),
  & > span:not(.divider) {
    margin: 0 20px;
    cursor: pointer;
  }

  .divider {
    height: 14px;
    width: 1px;
    margin: 0 20px;
    border-left: 1px solid #dcdfe6;
  }
}

.process-container {
  position: relative;
  overflow: hidden;

  .el-aside {
    position: absolute;
    top: 0;
    background: #fff;
    z-index: 1;
    height: 100%;
  }

  .left-aside {
    padding: 0 10px;
    left: 0;
    border-right: 1px solid #dcdfe6;
  }

  .right-aside {
    right: -500px;
    border-left: 1px solid #dcdfe6;
    transition: all 0.3s;

    &_visible {
      right: 0;
    }
  }
}

.process-nodes {
  .el-collapse {
    border-top-color: transparent;
  }

  .el-collapse ::v-deep {
    .el-collapse-item__header {
      height: 40px;
      line-height: 40px;
      padding-left: 10px;
    }

    .el-collapse-item__content {
      padding: 0;
    }
  }
}
</style>
<style lang="scss">
.custom-svg-element {
  polygon:not(.render),
  path:not(.render),
  circle:not(.render) {
    display: none;
  }
}
</style>
